go to previous page   go to home page   go to next page

Answer:

sliderV.addChangeListener( this ); 

Slider Names

There may be several sliders in your user interface. They may all generate events which may all be sent to the same listener. Give each slider a name so that the events can be sorted out correctly. (Another way is to register a separate listener for each slider). A name is a string that can be assigned to any object that inherits from class Component. Assign it using:

component.setName( String name )

Of course you must make sure that components that share the same listener have unique names.


QUESTION 9:

Assign names to the two sliders.

sliderA = new JSlider( JSlider.HORIZONTAL, 0, 1000, 400);
sliderB = new JSlider( JSlider.HORIZONTAL, 0, 1000, 400);
 . . . 
sliderA.setName(  ); 
sliderb.setName(  ); 

sliderA.addChangeListener( this ); 
sliderB.addChangeListener( this );